package com.bjmashibing;

import com.bjmashibing.util.TimeTool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.CountDownLatch;

/**
 * <p></p>
 *
 * @author sunzhiqiang23
 * @date 2020-05-12 16:58
 */
public class logbackDemo {

    public final static Logger logger =  LoggerFactory.getLogger(logbackDemo.class);

    public final static int THREAD_NUM = 100;
    public final static int LOOP_NUM = 100000;
    public final static CountDownLatch countDownLatch = new CountDownLatch(THREAD_NUM);

    public static void main(String[] args) throws Exception{
        TimeTool.check("单线程-同步",()->{
            test();
        });
    }

    public static void testThread() throws InterruptedException {

        for(int x= 0;x < THREAD_NUM;x++){
            new Thread(() -> {
                for (int y = 0; y < LOOP_NUM; y++) {
                    logger.info("Info Message!");
                }
                countDownLatch.countDown();
            }).start();
        }
        countDownLatch.await();
    }

    public static void test() {
        for(int x=0;x<THREAD_NUM;x++) {
            for (int y = 0; y < LOOP_NUM; y++) {
                logger.info("Info Message!");
            }
        }
    }
}
